//导入request.ts
import request from "@/request/index";
const AUTH_BASE_URL = "/rest/app";

export const AuthAPI = {
    /** 注册 接口*/
    register(data: RegisterData) {
      return request<any, LoginResult>({
        url: `${AUTH_BASE_URL}/register`,
        method: "post",
        data: data,
        headers: { "Content-Type": "application/json;charset=utf-8" },
      });
    },
    /** 扫码登录 接口*/
    scanLogin(queryParams: scanLoginData) {
      // return request<any, LoginResult>({
      //   url: `${AUTH_BASE_URL}/login`,
      //   method: "post",
      //   data: data,
      //   headers: { "Content-Type": "application/json;charset=utf-8" },
      // });
      return request<any, LoginResult>({
        method: "get",
        params: queryParams,
        url: `${AUTH_BASE_URL}/thirdLogin`,
      });
    },
    /** 登录 接口*/
    login(data: LoginData) {
      return request<any, LoginResult>({
        url: `${AUTH_BASE_URL}/login`,
        method: "post",
        data: data,
        headers: { "Content-Type": "application/json;charset=utf-8" },
      });
    },
    /** 谷歌登录 接口*/
    googleLogin(data: GoogleLoginData) {
      return request<any, LoginResult>({
        url: `${AUTH_BASE_URL}/googleLogin`,
        method: "post",
        data: data,
        headers: { "Content-Type": "application/json;charset=utf-8" },
      });
    },
  
    /** 注销 接口*/
    logout() {
      return request({
        url: `${AUTH_BASE_URL}/logout`,
        method: "delete",
      });
    },
  
    /** 获取验证码 接口*/
    getCaptcha() {
      return request<any, CaptchaResult>({
        url: `${AUTH_BASE_URL}/captcha`,
        method: "get",
      });
    },
  };
export  const PhoneAPI = {
    getphoneModel() {
      return request({
        url: `${AUTH_BASE_URL}/material/treeList?type=11`,
        method: "get",
      });
    },
    getMaterialList() {
      return request({
        url: `${AUTH_BASE_URL}/material/list?type=10`,
        method: "get",
      });
    }
}
export const typeList = () => {
  return request({
    url: `${AUTH_BASE_URL}/sticker/typeList`,
    method: "get",
  });
}
export const stickerList = (materialMap:MaterialMapData ,lastSort: number | null, type: number, algorithmName: string, styleIds: Array<number>, pageSize: number) => {
	return request({
		url: `${AUTH_BASE_URL}/sticker/list`,
		method: 'post',
    data: {materialMap,lastSort, type, algorithmName, styleIds, pageSize},
	})
}
export const skuList = (materialMap:any ,pageSize: number) => {
	return request({
		url: `${AUTH_BASE_URL}/sku/list`,
		method: 'post',
    data: {materialMap, pageSize},
	})
}


  
  /** 登录请求参数 */
  export interface LoginData {
    /** 用户名 */
    email: string;
    /** 密码 */
    password: string;
    /** 验证码缓存key */
    captchaKey: string;
    /** 验证码 */
    captchaCode: string;
  }
  
/** 谷歌登录请求参数 */
export interface GoogleLoginData {
  /**  */
  clientId: string;
  /**  */
  credential: string;
}

/** 登录请求参数 */
export interface RegisterData {
  /** 用户名 */
  email: string;
  /** 密码 */
  password: string;
  /** 确认密码 */
  newPassword: string;
}
  /** 扫码登录请求参数 */
  export interface scanLoginData {
    /** 扫码参数 */
    id: number;
  }
/** 登录响应 */
export interface LoginResult {
  /** 访问token */
  accessToken?: string;
  /** 过期时间(单位：毫秒) */
  expires?: number;
  /** 刷新token */
  refreshToken?: string;
  /** token 类型 */
  tokenType?: string;
}

/** 验证码响应 */
export interface CaptchaResult {
  /** 验证码缓存key */
  captchaKey: string;
  /** 验证码图片Base64字符串 */
  captchaBase64: string;
}

export interface MaterialMapData {
  10: number;
  11: number;
};